package zhang.automobileservice;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ListView;

import java.util.ArrayList;

import adapter.MyCarAdapter;
import bean.MyCarBean;

public class MycarActivity extends FarterActivity implements View.OnClickListener {

    private ImageButton finish;
    private ImageButton tb_addcar;
    private ListView lv_mycar;
    private ArrayList<MyCarBean> arrayList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mycar);
        initView();
        initData();
        lv_mycar.setAdapter(new MyCarAdapter(this,arrayList));
    }

    private void initData() {

        arrayList = new ArrayList<>();
        arrayList.add(new MyCarBean("豫A55", "正常", "宝马", "9", "99", "12"));
        arrayList.add(new MyCarBean("豫A56", "正常", "奥迪", "10", "100", "12"));
        arrayList.add(new MyCarBean("豫A57", "正常", "沃尔沃", "12", "1000", "12"));

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.finish:
                finish();
                break;
            case R.id.tb_addcar:
                Intent intent  =new Intent(this,AddCarActivity.class);
                startActivity(intent);
                break;
        }

    }

    private void initView() {
        finish = (ImageButton) findViewById(R.id.finish);
        tb_addcar = (ImageButton) findViewById(R.id.tb_addcar);
        lv_mycar = (ListView) findViewById(R.id.lv_mycar);

        finish.setOnClickListener(this);
        tb_addcar.setOnClickListener(this);
    }
}
